package tech.aistar.corejava.day08.factory;

/**
 * @author success
 * @version 1.0
 * @description:本类用来演示:简单工厂设计模式
 * @date 2019/7/24 0024
 */
public class MyBeanFactory {
    //根据传入的参数来返回具体的某个bean
    public static final int V_ONE = 1;

    public static final int V_TWO = 2;

    public static final int V_THREE = 3;

    //多态的应用 - 面向接口编程 - 特性3
    //方法的返回类型写成接口,方法的执行结果可以写成接口的某个实现类.
    public static IUserDao getInstance(int type){
        //return new UserDaoImpl();//创建bean的语法
        //return new UserDaoImpl2();
        IUserDao userDao = null;
        switch(type){
            case V_ONE:
                userDao = new UserDaoImpl();
                break;
            case V_TWO:
                userDao = new UserDaoImpl2();
                break;
            case V_THREE:
                userDao = new UserDaoImpl3();
                break;
        }
        return userDao;
    }
}
